<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<input type="text" id="input">
	<button id="aa">点击</button>
</body>
</html>

<script>
	ws = new WebSocket('ws://127.0.0.1:3389');

	ws.onopen = function()
	{
		var a = 'sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss';
	    ws.send(a);
	};

	ws.onmessage = function(evt)
	{
	  console.log(evt.data)
	};

	ws.onclose = function(evt)
	{
	  console.log('WebSocketClosed!');
	};

	ws.onerror = function(evt)
	{
	  console.log('WebSocketError!');
	};

	var a = document.getElementById("aa")
	a.onclick = function(){
	    msg = document.getElementById("input").value
		if(msg){
		    ws.send(msg);
		}

		document.getElementById("input").value = ''
	}
</script>